/*
 * Moseycode
 * Copyright (C) 2008  Tom Gibara
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package com.tomgibara.mosey.portal.render;

/**
 * Implementations of this interface may be used to control how
 * a PortalPainter renders aspects of a portal.
 * 
 * Implementors may choose to extend {@link Base} for convenience.
 * 
 * Colors are specified as per the {@link GenericGraphics} class.
 * 
 * @author Tom Gibara
 *
 */

public interface PortalPainterCustomizer {

	/**
	 * @return the foreground color (black as standard)
	 */
	int getForegroundColor();

	/**
	 * @return the background color (white as standard)
	 */
	int getBackgroundColor();
	
	/**
	 * @return the color used to draw the portal registration markers (black as standard)
	 */
	int getTargetColor();

	/**
	 * Renders the quiet area (background square) of the portal.
	 * 
	 * @param g the graphical context
	 * @return true if this object rendered the quiet area, false if this task was left to the {@link PortalPainter} 
	 */
	boolean setQuietArea(GenericGraphics g);

	/**
	 * Called to render any embelishments that appear over the quiet area, but
	 * below the bits.
	 * 
	 * @param g the graphical context
	 */
	void renderDecoration(GenericGraphics g);
	
	/**
	 * Render a single data bit.
	 * 
	 * @param g the graphical context
	 * @param x the x coordinate of the bit's center
	 * @param y the y coordinate of the bit's center
	 * @param on whether the bit is on (has value 1) or off (has value 0)
	 * @return true if this object rendered the bit, false if this task was left to the {@link PortalPainter} 
	 */
	boolean renderDataBit(GenericGraphics g, float x, float y, boolean on);

	/**
	 * Render a single edge bit.
	 * 
	 * @param g the graphical context
	 * @param x the x coordinate of the bit's center
	 * @param y the y coordinate of the bit's center
	 * @param on whether the bit is on (has value 1) or off (has value 0)
	 * @return true if this object rendered the bit, false if this task was left to the {@link PortalPainter} 
	 */
	boolean renderEdgeBit(GenericGraphics g, float x, float y, boolean on);

	/**
	 * NOT CURRENTLY USED 
	 */
	void renderDecal(GenericGraphics g);

	/**
	 * A standard implementation of the {@link PortalPainterCustomizer} class.
	 * This serves as a useful base class for PortalPainterCustomizer implementations. 
	 * 
	 * @author Tom Gibara 
	 *
	 */
	
	public static class Base implements PortalPainterCustomizer {

		@Override
		public int getBackgroundColor() {
			return 0xffffffff;
		}

		@Override
		public int getForegroundColor() {
			return 0x00000000;
		}

		@Override
		public int getTargetColor() {
			return 0x00000000;
		}

		@Override
		public boolean renderDataBit(GenericGraphics g, float x, float y, boolean on) {
			return false;
		}

		@Override
		public void renderDecal(GenericGraphics g) {
		}

		@Override
		public void renderDecoration(GenericGraphics g) {
		}

		@Override
		public boolean renderEdgeBit(GenericGraphics g, float x, float y, boolean on) {
			return false;
		}

		@Override
		public boolean setQuietArea(GenericGraphics g) {
			return false;
		}
		
		
		
	}
	
}
